package io.gitee.yth.design.pattern.test.core.pattern.creational.factory.pizzaorderservice;

import io.gitee.yth.design.pattern.test.core.pattern.creational.factory.pizza.GreekPizza;
import io.gitee.yth.design.pattern.test.core.pattern.creational.factory.pizza.PepperPizza;
import io.gitee.yth.design.pattern.test.core.pattern.creational.factory.pizza.Pizza;

/**
 * 不用设计模式的原始方法
 *
 * @author yth
 * @since 2023-04-17-0:21
 */
public class PizzaOrderServiceImpl1 implements IPizzaOrderService {

    @Override
    public Pizza orderPizza(String orderType) {
        Pizza pizza;
        switch (orderType) {
            case "greek":
                pizza = new GreekPizza();
                break;
            case "pepper":
                pizza = new PepperPizza();
                break;
            default:
                pizza = null;
                break;
        }

        if (pizza == null) return null;
        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();
        return pizza;
    }

}
